### CODE FOR:
###
### Partisan Influence on Policy Preferences 
### When Parties and Voters Disagree on Welfare Retrenchment
###
### PART 2-2: Descriptive (policy) preference changes
###           for OPPOSITION voters (Figure C1)
###
### VERSION: 2024-MAR-01


rm(list=ls())
gc()



# WORKING DIRECTORY -------------------------------------------------------
setwd("C:/Users/miros/Desktop/Research/Finland - Partisan Cues in Citizens Attitudes")



# LIBRARIES ---------------------------------------------------------------
library(tidyverse)
library(ggplot2)
library(RColorBrewer)
library(grid)
library(ggpubr)
library(patchwork)
library(ggalluvial)
library(scales)



# DATA IMPORT -------------------------------------------------------------
# NOTE: The data file loaded in the next step was prepared in a separate
#       scripts '01_PartyCues-data_prep.R'. If you haven't run the script, 
#       return to the depository and run that script first. Its output is 
#       'BIBU_long.Rda' loaded in the next step.
load("01-data/BIBU_long.Rda")




# DATA PREPARATION --------------------------------------------------------

# Policy preferences into binary variables
BIBU.DiD <-
  BIBU.DiD %>%
  mutate(RETIREMENT_TUBE_BI = as.factor(
    ifelse((RETIREMENT_TUBE == 1 | RETIREMENT_TUBE == 2), "Strongly/Somewhat disagree",
           ifelse((RETIREMENT_TUBE == 3 | RETIREMENT_TUBE == 4), "Strongly/Somewhat agree",
                  NA)))) %>%
  
  mutate(COMPULSORY_SCHOOLING_BI = as.factor(
    ifelse((COMPULSORY_SCHOOLING == 1 | COMPULSORY_SCHOOLING == 2), "Strongly/Somewhat disagree",
           ifelse((COMPULSORY_SCHOOLING == 3 | COMPULSORY_SCHOOLING == 4), "Strongly/Somewhat agree",
                  NA))))




# FIGURE 2 ----------------------------------------------------------------

# _ National Coalition ----------------------------------------------------

# __ Data preparation -----------------------------------------------------
BIBU.NatC <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, RETIREMENT_TUBE_BI, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "National Coalition") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-count)

BIBU.NatC <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, COMPULSORY_SCHOOLING_BI, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "National Coalition") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-c(count, PartyChoice.Overall)) %>%
  full_join(., BIBU.NatC, by = c("MEMBERID", "ROUND"))

BIBU.NatC <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, LeftRight, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "National Coalition") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-c(count, PartyChoice.Overall)) %>%
  full_join(., BIBU.NatC, by = c("MEMBERID", "ROUND"))

BIBU.NatC$PartyChoice.Overall <- "National Coalition"



# __ Figure ---------------------------------------------------------------

NatCol <-
  ggarrange(
    # Kernel density plot
    ggplot(filter(BIBU.NatC, !is.na(LeftRight) & ROUND == "Round 1"), 
           aes(x = LeftRight)) +
      geom_density(alpha = 0.65, 
                   bw = 0.75, 
                   color = brewer.pal(n = 9, name = "Greys")[5],
                   fill = brewer.pal(n = 9, name = "Greys")[3]) +
      geom_segment(x = mean(BIBU.NatC$LeftRight), 
                   xend = mean(BIBU.NatC$LeftRight), 
                   y = 0, 
                   yend = 0.315, 
                   color = brewer.pal(n = 9, name = "Greys")[7], 
                   linetype = "longdash") +
      scale_x_continuous(breaks = seq(0, 10, 1), labels = c("0", "\nLeft", "", "", "", "5", "", "", "", "\nRight", "10")) +
      scale_y_continuous(breaks = seq(0, 0.5, 0.05), labels = c("0.0", "", "0.1", "", "0.2", "", "0.3", "", "0.4", "", "0.5")) +
      labs(title = NULL, x = NULL, y = NULL, fill = NULL, color = NULL) +
      geom_rect(ymin = 0.5 * 1.05, ymax = 0.5 * 1.25, xmin = 0 - 0.33, xmax = 10 + 0.33, colour = "black", fill = "grey90") +
      annotate("text", x = 5, y = 0.5 * 1.14, hjust = 0.5, vjust = -0.2, label = "Left-right distribution", fontface = 2, size = 13/.pt) +
      annotate("text", x = 5, y = 0.5 * 1.14, hjust = 0.5, vjust = 1.2, label = "as measured in Round 1", size = 10/.pt) +
      coord_cartesian(xlim = c(0 - 0.33, 10 + 0.33), ylim = c(0, 0.5 * 1.25), expand = FALSE, clip = "off") +
      theme(text = element_text(size = 12, color = "black"),
            axis.text.x = element_blank(),
            panel.grid.major.x = element_blank(), 
            panel.grid.major.y = element_line(colour = "gray90"), 
            panel.grid.minor.y = element_blank(), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent"),
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.35, 0.2, 0.05, 0.05),"cm")),
    
    
    # Welfare retrenchment
    ggplot(filter(BIBU.NatC, !is.na(RETIREMENT_TUBE_BI)), 
           aes(x = ROUND, 
               stratum = RETIREMENT_TUBE_BI, 
               fill = as.factor(RETIREMENT_TUBE_BI), 
               alluvium = MEMBERID)) +
      scale_fill_manual(values = brewer.pal(n = 9, name = "Greys")[c(6, 4)]) +
      geom_flow(width = 0.75) +
      geom_stratum(alpha = 0.5, width = 0.75) + 
      geom_text(stat = "stratum", color = "black", aes(label = percent(after_stat(prop), accuracy = .1)), size = 11/.pt, vjust = -0.1) +
      geom_text(stat = "stratum", color = "black", aes(label = paste0("(N=",after_stat(count),")")), size = 8.5/.pt, vjust = 1.1) +
      scale_x_discrete(limits = c("Round 1", "Round 2"), labels = c("Before\nthe reform", "After\nthe reform")) +
      labs(title = NULL, x = NULL, y = NULL) +
      coord_cartesian(xlim = c(0.6, 2.4), 
                      ylim = c(-(nrow(filter(BIBU.NatC, !is.na(RETIREMENT_TUBE_BI)))/2)*0.01, 
                               (nrow(filter(BIBU.NatC, !is.na(RETIREMENT_TUBE_BI)))/2)*1.25), 
                      expand = FALSE, 
                      clip = "off") +
      scale_y_continuous(breaks = seq(from = 0, 
                                      to = nrow(filter(BIBU.NatC, !is.na(RETIREMENT_TUBE_BI)))/2, 
                                      by = nrow(filter(BIBU.NatC, !is.na(RETIREMENT_TUBE_BI)))/10),
                         labels = c("0%", "20%", "40%", "60%", "80%", "100%")) +
      geom_rect(ymin = (nrow(filter(BIBU.NatC, !is.na(RETIREMENT_TUBE_BI)))/2)*1.05, 
                ymax = (nrow(filter(BIBU.NatC, !is.na(RETIREMENT_TUBE_BI)))/2)*1.25, 
                xmin = 0.6, 
                xmax = 2.4, 
                colour = "black", 
                fill = "grey90") +
      annotate("text", x = 1.5, y = (nrow(filter(BIBU.NatC, !is.na(RETIREMENT_TUBE_BI)))/2)*1.14, hjust = 0.5, vjust = -0.2, label = "Welfare retrenchment", fontface = 2, size = 13/.pt) +
      annotate("text", x = 1.5, y = (nrow(filter(BIBU.NatC, !is.na(RETIREMENT_TUBE_BI)))/2)*1.14, hjust = 0.5, vjust =  1.2, label = "Abolition of the 'retirement tube'", size = 10/.pt) +
      theme(text = element_text(size = 12, color = "black"),
            axis.text.x = element_blank(),
            panel.grid.major.x = element_blank(),
            panel.grid.minor.x = element_blank(), 
            panel.grid.major.y = element_line(color = "grey90"),
            panel.grid.minor.y = element_line(color = "grey90"), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent", color = "transparent"),
            legend.position = "none", 
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.35, 0.05, 0.15, 0.05),"cm")),
    
    
    # Welfare expansion
    ggplot(filter(BIBU.NatC, !is.na(COMPULSORY_SCHOOLING_BI)), 
           aes(x = ROUND, 
               stratum = COMPULSORY_SCHOOLING_BI, 
               fill = as.factor(COMPULSORY_SCHOOLING_BI), 
               alluvium = MEMBERID)) +
      scale_fill_manual(values = brewer.pal(n = 9, name = "Greys")[c(6, 4)]) +
      geom_flow(width = 0.75) +
      geom_stratum(alpha = 0.5, width = 0.75) + 
      geom_text(stat = "stratum", color = "black", aes(label = percent(after_stat(prop), accuracy = .1)), size = 11/.pt, vjust = -0.1) +
      geom_text(stat = "stratum", color = "black", aes(label = paste0("(N=",after_stat(count),")")), size = 8.5/.pt, vjust = 1.1) +
      scale_x_discrete(limits = c("Round 1", "Round 2"), labels = c("Before\nthe reform", "After\nthe reform")) +
      labs(title = NULL, x = NULL, y = NULL) +
      coord_cartesian(xlim = c(0.6, 2.6), 
                      ylim = c(-(nrow(filter(BIBU.NatC, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.01, 
                               (nrow(filter(BIBU.NatC, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.25), 
                      expand = FALSE, 
                      clip = "off") +
      scale_y_continuous(breaks = seq(from = 0, 
                                      to = nrow(filter(BIBU.NatC, !is.na(COMPULSORY_SCHOOLING_BI)))/2, 
                                      by = nrow(filter(BIBU.NatC, !is.na(COMPULSORY_SCHOOLING_BI)))/10),
                         labels = c("0%", "20%", "40%", "60%", "80%", "100%")) +
      geom_rect(ymin = (nrow(filter(BIBU.NatC, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.05, 
                ymax = (nrow(filter(BIBU.NatC, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.25, 
                xmin = 0.6, 
                xmax = 2.4, 
                colour = "black", 
                fill = "grey90") +
      annotate("text", x = 1.5, y = (nrow(filter(BIBU.NatC, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.14, hjust = 0.5, vjust = -0.2, label = "Welfare expansion", fontface = 2, size = 13/.pt) +
      annotate("text", x = 1.5, y = (nrow(filter(BIBU.NatC, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.14, hjust = 0.5, vjust =  1.2, label = "Extension of the compulsory school age", size = 10/.pt) +
      geom_rect(ymin = -(nrow(filter(BIBU.NatC, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.01, 
                ymax =  (nrow(filter(BIBU.NatC, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.01, 
                xmin = 2.4, 
                xmax = 2.6, 
                colour = "black", 
                fill = "grey90") +
      annotate("text", x = 2.5, y = (nrow(filter(BIBU.NatC, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.5, hjust = 0.5, vjust = 0.5, label = "National Coalition", angle = 270, fontface = 2, size = 13/.pt) +
      theme(text = element_text(size = 12, color = "black"),
            axis.text.x = element_blank(),
            panel.grid.major.x = element_blank(),
            panel.grid.minor.x = element_blank(), 
            panel.grid.major.y = element_line(color = "grey90"),
            panel.grid.minor.y = element_line(color = "grey90"), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent", color = "transparent"),
            legend.position = "none", 
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.35, 0.05, 0.15, 0.05),"cm")),
    
    # General specs
    ncol = 3, widths = c(3, 4, 4.25),
    align = "hv")





# _ Christian Democrats ---------------------------------------------------

# __ Data preparation -----------------------------------------------------
BIBU.ChD <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, RETIREMENT_TUBE_BI, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "Christian Democrats") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-count)

BIBU.ChD <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, COMPULSORY_SCHOOLING_BI, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "Christian Democrats") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-c(count, PartyChoice.Overall)) %>%
  full_join(., BIBU.ChD, by = c("MEMBERID", "ROUND"))

BIBU.ChD <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, LeftRight, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "Christian Democrats") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-c(count, PartyChoice.Overall)) %>%
  full_join(., BIBU.ChD, by = c("MEMBERID", "ROUND"))

BIBU.ChD$PartyChoice.Overall <- "Christian Democrats"



# __ Figure ---------------------------------------------------------------

ChristianDem <-
  ggarrange(
    # Kernel density plot
    ggplot(filter(BIBU.ChD, !is.na(LeftRight) & ROUND == "Round 1"), 
           aes(x = LeftRight)) +
      geom_density(alpha = 0.65, 
                   bw = 0.75, 
                   color = brewer.pal(n = 9, name = "Greys")[5],
                   fill = brewer.pal(n = 9, name = "Greys")[3]) +
      geom_segment(x = mean(BIBU.ChD$LeftRight), 
                   xend = mean(BIBU.ChD$LeftRight), 
                   y = 0, 
                   yend = 0.2, 
                   color = brewer.pal(n = 9, name = "Greys")[7], 
                   linetype = "longdash") +
      scale_x_continuous(breaks = seq(0, 10, 1), labels = c("0", "\nLeft", "", "", "", "5", "", "", "", "\nRight", "10")) +
      scale_y_continuous(breaks = seq(0, 0.5, 0.05), labels = c("0.0", "", "0.1", "", "0.2", "", "0.3", "", "0.4", "", "0.5")) +
      labs(title = NULL, x = NULL, y = NULL, fill = NULL, color = NULL) +
      coord_cartesian(xlim = c(0 - 0.33, 10 + 0.33), ylim = c(0, 0.5 * 1.01), expand = FALSE, clip = "off") +
      theme(text = element_text(size = 12, color = "black"),
            axis.text.x = element_blank(),
            panel.grid.major.x = element_blank(), 
            panel.grid.major.y = element_line(colour = "gray90"), 
            panel.grid.minor.y = element_blank(), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent"),
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.05, 0.2, 0.05, 0.05),"cm")),
    
    
    # Welfare retrenchment
    ggplot(filter(BIBU.ChD, !is.na(RETIREMENT_TUBE_BI)), 
           aes(x = ROUND, 
               stratum = RETIREMENT_TUBE_BI, 
               fill = as.factor(RETIREMENT_TUBE_BI), 
               alluvium = MEMBERID)) +
      scale_fill_manual(values = brewer.pal(n = 9, name = "Greys")[c(6, 4)]) +
      geom_flow(width = 0.75) +
      geom_stratum(alpha = 0.5, width = 0.75) + 
      geom_text(stat = "stratum", color = "black", aes(label = percent(after_stat(prop), accuracy = .1)), size = 11/.pt, vjust = -0.1) +
      geom_text(stat = "stratum", color = "black", aes(label = paste0("(N=",after_stat(count),")")), size = 8.5/.pt, vjust = 1.1) +
      scale_x_discrete(limits = c("Round 1", "Round 2"), labels = c("Before\nthe reform", "After\nthe reform")) +
      labs(title = NULL, x = NULL, y = NULL) +
      coord_cartesian(xlim = c(0.6, 2.4), 
                      ylim = c(-(nrow(filter(BIBU.ChD, !is.na(RETIREMENT_TUBE_BI)))/2)*0.01, 
                               (nrow(filter(BIBU.ChD, !is.na(RETIREMENT_TUBE_BI)))/2)*1.01), 
                      expand = FALSE, 
                      clip = "off") +
      scale_y_continuous(breaks = seq(from = 0, 
                                      to = nrow(filter(BIBU.ChD, !is.na(RETIREMENT_TUBE_BI)))/2, 
                                      by = nrow(filter(BIBU.ChD, !is.na(RETIREMENT_TUBE_BI)))/10),
                         labels = c("0%", "20%", "40%", "60%", "80%", "100%")) +
      theme(text = element_text(size = 12, color = "black"),
            axis.text.x = element_blank(),
            panel.grid.major.x = element_blank(),
            panel.grid.minor.x = element_blank(), 
            panel.grid.major.y = element_line(color = "grey90"),
            panel.grid.minor.y = element_line(color = "grey90"), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent", color = "transparent"),
            legend.position = "none", 
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.15, 0.05, 0.15, 0.05),"cm")),
    
    
    # Welfare expansion
    ggplot(filter(BIBU.ChD, !is.na(COMPULSORY_SCHOOLING_BI)), 
           aes(x = ROUND, 
               stratum = COMPULSORY_SCHOOLING_BI, 
               fill = as.factor(COMPULSORY_SCHOOLING_BI), 
               alluvium = MEMBERID)) +
      scale_fill_manual(values = brewer.pal(n = 9, name = "Greys")[c(6, 4)]) +
      geom_flow(width = 0.75) +
      geom_stratum(alpha = 0.5, width = 0.75) + 
      geom_text(stat = "stratum", color = "black", aes(label = percent(after_stat(prop), accuracy = .1)), size = 11/.pt, vjust = -0.1) +
      geom_text(stat = "stratum", color = "black", aes(label = paste0("(N=",after_stat(count),")")), size = 8.5/.pt, vjust = 1.1) +
      scale_x_discrete(limits = c("Round 1", "Round 2"), labels = c("Before\nthe reform", "After\nthe reform")) +
      labs(title = NULL, x = NULL, y = NULL) +
      coord_cartesian(xlim = c(0.6, 2.6), 
                      ylim = c(-(nrow(filter(BIBU.ChD, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.01, 
                               (nrow(filter(BIBU.ChD, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.01), 
                      expand = FALSE, 
                      clip = "off") +
      scale_y_continuous(breaks = seq(from = 0, 
                                      to = nrow(filter(BIBU.ChD, !is.na(COMPULSORY_SCHOOLING_BI)))/2, 
                                      by = nrow(filter(BIBU.ChD, !is.na(COMPULSORY_SCHOOLING_BI)))/10),
                         labels = c("0%", "20%", "40%", "60%", "80%", "100%")) +
      geom_rect(ymin = -(nrow(filter(BIBU.ChD, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.01, 
                ymax =  (nrow(filter(BIBU.ChD, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.01, 
                xmin = 2.4, 
                xmax = 2.6, 
                colour = "black", 
                fill = "grey90") +
      annotate("text", x = 2.5, y = (nrow(filter(BIBU.ChD, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.5, hjust = 0.5, vjust = 0.5, label = "Christian Democrats", angle = 270, fontface = 2, size = 13/.pt) +
      theme(text = element_text(size = 12, color = "black"),
            axis.text.x = element_blank(),
            panel.grid.major.x = element_blank(),
            panel.grid.minor.x = element_blank(), 
            panel.grid.major.y = element_line(color = "grey90"),
            panel.grid.minor.y = element_line(color = "grey90"), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent", color = "transparent"),
            legend.position = "none", 
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.15, 0.05, 0.15, 0.05),"cm")),
    
    # General specs
    ncol = 3, widths = c(3, 4, 4.25),
    align = "hv")





# _ Other -----------------------------------------------------------------

# __ Data preparation -----------------------------------------------------
BIBU.Other <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, RETIREMENT_TUBE_BI, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "Other") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-count)

BIBU.Other <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, COMPULSORY_SCHOOLING_BI, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "Other") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-c(count, PartyChoice.Overall)) %>%
  full_join(., BIBU.Other, by = c("MEMBERID", "ROUND"))

BIBU.Other <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, LeftRight, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "Other") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-c(count, PartyChoice.Overall)) %>%
  full_join(., BIBU.Other, by = c("MEMBERID", "ROUND"))

BIBU.Other$PartyChoice.Overall <- "Other"



# __ Figure ---------------------------------------------------------------

Other <-
  ggarrange(
    # Kernel density plot
    ggplot(filter(BIBU.Other, !is.na(LeftRight) & ROUND == "Round 1"), 
           aes(x = LeftRight)) +
      geom_density(alpha = 0.65, 
                   bw = 0.75, 
                   color = brewer.pal(n = 9, name = "Greys")[5],
                   fill = brewer.pal(n = 9, name = "Greys")[3]) +
      geom_segment(x = mean(BIBU.Other$LeftRight), 
                   xend = mean(BIBU.Other$LeftRight), 
                   y = 0, 
                   yend = 0.1, 
                   color = brewer.pal(n = 9, name = "Greys")[7], 
                   linetype = "longdash") +
      scale_x_continuous(breaks = seq(0, 10, 1), labels = c("0", "\nLeft", "", "", "", "5", "", "", "", "\nRight", "10")) +
      scale_y_continuous(breaks = seq(0, 0.5, 0.05), labels = c("0.0", "", "0.1", "", "0.2", "", "0.3", "", "0.4", "", "0.5")) +
      labs(title = NULL, x = NULL, y = NULL, fill = NULL, color = NULL) +
      coord_cartesian(xlim = c(0 - 0.33, 10 + 0.33), ylim = c(0, 0.5 * 1.01), expand = FALSE, clip = "off") +
      theme(text = element_text(size = 12, color = "black"),
            axis.text.x = element_blank(),
            panel.grid.major.x = element_blank(), 
            panel.grid.major.y = element_line(colour = "gray90"), 
            panel.grid.minor.y = element_blank(), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent"),
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.05, 0.2, 0.05, 0.05),"cm")),
    
    
    # Welfare retrenchment
    ggplot(filter(BIBU.Other, !is.na(RETIREMENT_TUBE_BI)), 
           aes(x = ROUND, 
               stratum = RETIREMENT_TUBE_BI, 
               fill = as.factor(RETIREMENT_TUBE_BI), 
               alluvium = MEMBERID)) +
      scale_fill_manual(values = brewer.pal(n = 9, name = "Greys")[c(6, 4)]) +
      geom_flow(width = 0.75) +
      geom_stratum(alpha = 0.5, width = 0.75) + 
      geom_text(stat = "stratum", color = "black", aes(label = percent(after_stat(prop), accuracy = .1)), size = 11/.pt, vjust = -0.1) +
      geom_text(stat = "stratum", color = "black", aes(label = paste0("(N=",after_stat(count),")")), size = 8.5/.pt, vjust = 1.1) +
      scale_x_discrete(limits = c("Round 1", "Round 2"), labels = c("Before\nthe reform", "After\nthe reform")) +
      labs(title = NULL, x = NULL, y = NULL) +
      coord_cartesian(xlim = c(0.6, 2.4), 
                      ylim = c(-(nrow(filter(BIBU.Other, !is.na(RETIREMENT_TUBE_BI)))/2)*0.01, 
                               (nrow(filter(BIBU.Other, !is.na(RETIREMENT_TUBE_BI)))/2)*1.01), 
                      expand = FALSE, 
                      clip = "off") +
      scale_y_continuous(breaks = seq(from = 0, 
                                      to = nrow(filter(BIBU.Other, !is.na(RETIREMENT_TUBE_BI)))/2, 
                                      by = nrow(filter(BIBU.Other, !is.na(RETIREMENT_TUBE_BI)))/10),
                         labels = c("0%", "20%", "40%", "60%", "80%", "100%")) +
      theme(text = element_text(size = 12, color = "black"),
            axis.text.x = element_blank(),
            panel.grid.major.x = element_blank(),
            panel.grid.minor.x = element_blank(), 
            panel.grid.major.y = element_line(color = "grey90"),
            panel.grid.minor.y = element_line(color = "grey90"), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent", color = "transparent"),
            legend.position = "none", 
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.15, 0.05, 0.15, 0.05),"cm")),
    
    
    # Welfare expansion
    ggplot(filter(BIBU.Other, !is.na(COMPULSORY_SCHOOLING_BI)), 
           aes(x = ROUND, 
               stratum = COMPULSORY_SCHOOLING_BI, 
               fill = as.factor(COMPULSORY_SCHOOLING_BI), 
               alluvium = MEMBERID)) +
      scale_fill_manual(values = brewer.pal(n = 9, name = "Greys")[c(6, 4)]) +
      geom_flow(width = 0.75) +
      geom_stratum(alpha = 0.5, width = 0.75) + 
      geom_text(stat = "stratum", color = "black", aes(label = percent(after_stat(prop), accuracy = .1)), size = 11/.pt, vjust = -0.1) +
      geom_text(stat = "stratum", color = "black", aes(label = paste0("(N=",after_stat(count),")")), size = 8.5/.pt, vjust = 1.1) +
      scale_x_discrete(limits = c("Round 1", "Round 2"), labels = c("Before\nthe reform", "After\nthe reform")) +
      labs(title = NULL, x = NULL, y = NULL) +
      coord_cartesian(xlim = c(0.6, 2.6), 
                      ylim = c(-(nrow(filter(BIBU.Other, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.01, 
                               (nrow(filter(BIBU.Other, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.01), 
                      expand = FALSE, 
                      clip = "off") +
      scale_y_continuous(breaks = seq(from = 0, 
                                      to = nrow(filter(BIBU.Other, !is.na(COMPULSORY_SCHOOLING_BI)))/2, 
                                      by = nrow(filter(BIBU.Other, !is.na(COMPULSORY_SCHOOLING_BI)))/10),
                         labels = c("0%", "20%", "40%", "60%", "80%", "100%")) +
      geom_rect(ymin = -(nrow(filter(BIBU.Other, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.01, 
                ymax =  (nrow(filter(BIBU.Other, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.01, 
                xmin = 2.4, 
                xmax = 2.6, 
                colour = "black", 
                fill = "grey90") +
      annotate("text", x = 2.5, y = (nrow(filter(BIBU.Other, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.5, hjust = 0.5, vjust = 0.5, label = "Other", angle = 270, fontface = 2, size = 13/.pt) +
      theme(text = element_text(size = 12, color = "black"),
            axis.text.x = element_blank(),
            panel.grid.major.x = element_blank(),
            panel.grid.minor.x = element_blank(), 
            panel.grid.major.y = element_line(color = "grey90"),
            panel.grid.minor.y = element_line(color = "grey90"), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent", color = "transparent"),
            legend.position = "none", 
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.15, 0.05, 0.15, 0.05),"cm")),
    
    # General specs
    ncol = 3, widths = c(3, 4, 4.25),
    align = "hv")





# _ True Finns ------------------------------------------------------------

# __ Data preparation -----------------------------------------------------
BIBU.Finns <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, RETIREMENT_TUBE_BI, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "True Finns") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-count)

BIBU.Finns <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, COMPULSORY_SCHOOLING_BI, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "True Finns") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-c(count, PartyChoice.Overall)) %>%
  full_join(., BIBU.Finns, by = c("MEMBERID", "ROUND"))

BIBU.Finns <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, LeftRight, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "True Finns") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-c(count, PartyChoice.Overall)) %>%
  full_join(., BIBU.Finns, by = c("MEMBERID", "ROUND"))

BIBU.Finns$PartyChoice.Overall <- "True Finns"



# __ Figure ---------------------------------------------------------------

TrueFinns <-
  ggarrange(
    # Kernel density plot
    ggplot(filter(BIBU.Finns, !is.na(LeftRight) & ROUND == "Round 1"), 
           aes(x = LeftRight)) +
      geom_density(alpha = 0.65, 
                   bw = 0.75, 
                   color = brewer.pal(n = 9, name = "Greys")[5],
                   fill = brewer.pal(n = 9, name = "Greys")[3]) +
      geom_segment(x = mean(BIBU.Finns$LeftRight), 
                   xend = mean(BIBU.Finns$LeftRight), 
                   y = 0, 
                   yend = 0.170, 
                   color = brewer.pal(n = 9, name = "Greys")[7], 
                   linetype = "longdash") +
      scale_x_continuous(breaks = seq(0, 10, 1), labels = c("0", "\nLeft", "", "", "", "5", "", "", "", "\nRight", "10")) +
      scale_y_continuous(breaks = seq(0, 0.5, 0.05), labels = c("0.0", "", "0.1", "", "0.2", "", "0.3", "", "0.4", "", "0.5")) +
      labs(title = NULL, x = NULL, y = NULL, fill = NULL, color = NULL) +
      coord_cartesian(xlim = c(0 - 0.33, 10 + 0.33), ylim = c(0, 0.5 * 1.01), expand = FALSE, clip = "off") +
      theme(text = element_text(size = 12, color = "black"),
            axis.text.x = element_blank(),
            panel.grid.major.x = element_blank(), 
            panel.grid.major.y = element_line(colour = "gray90"), 
            panel.grid.minor.y = element_blank(), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent"),
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.05, 0.2, 0.05, 0.05),"cm")),
    
    
    # Welfare retrenchment
    ggplot(filter(BIBU.Finns, !is.na(RETIREMENT_TUBE_BI)), 
           aes(x = ROUND, 
               stratum = RETIREMENT_TUBE_BI, 
               fill = as.factor(RETIREMENT_TUBE_BI), 
               alluvium = MEMBERID)) +
      scale_fill_manual(values = brewer.pal(n = 9, name = "Greys")[c(6, 4)]) +
      geom_flow(width = 0.75) +
      geom_stratum(alpha = 0.5, width = 0.75) + 
      geom_text(stat = "stratum", color = "black", aes(label = percent(after_stat(prop), accuracy = .1)), size = 11/.pt, vjust = -0.1) +
      geom_text(stat = "stratum", color = "black", aes(label = paste0("(N=",after_stat(count),")")), size = 8.5/.pt, vjust = 1.1) +
      scale_x_discrete(limits = c("Round 1", "Round 2"), labels = c("Before\nthe reform", "After\nthe reform")) +
      labs(title = NULL, x = NULL, y = NULL) +
      coord_cartesian(xlim = c(0.6, 2.4), 
                      ylim = c(-(nrow(filter(BIBU.Finns, !is.na(RETIREMENT_TUBE_BI)))/2)*0.01, 
                               (nrow(filter(BIBU.Finns, !is.na(RETIREMENT_TUBE_BI)))/2)*1.01), 
                      expand = FALSE, 
                      clip = "off") +
      scale_y_continuous(breaks = seq(from = 0, 
                                      to = nrow(filter(BIBU.Finns, !is.na(RETIREMENT_TUBE_BI)))/2, 
                                      by = nrow(filter(BIBU.Finns, !is.na(RETIREMENT_TUBE_BI)))/10),
                         labels = c("0%", "20%", "40%", "60%", "80%", "100%")) +
      theme(text = element_text(size = 12, color = "black"),
            axis.text.x = element_blank(),
            panel.grid.major.x = element_blank(),
            panel.grid.minor.x = element_blank(), 
            panel.grid.major.y = element_line(color = "grey90"),
            panel.grid.minor.y = element_line(color = "grey90"), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent", color = "transparent"),
            legend.position = "none", 
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.15, 0.05, 0.15, 0.05),"cm")),
    
    
    # Welfare expansion
    ggplot(filter(BIBU.Finns, !is.na(COMPULSORY_SCHOOLING_BI)), 
           aes(x = ROUND, 
               stratum = COMPULSORY_SCHOOLING_BI, 
               fill = as.factor(COMPULSORY_SCHOOLING_BI), 
               alluvium = MEMBERID)) +
      scale_fill_manual(values = brewer.pal(n = 9, name = "Greys")[c(6, 4)]) +
      geom_flow(width = 0.75) +
      geom_stratum(alpha = 0.5, width = 0.75) + 
      geom_text(stat = "stratum", color = "black", aes(label = percent(after_stat(prop), accuracy = .1)), size = 11/.pt, vjust = -0.1) +
      geom_text(stat = "stratum", color = "black", aes(label = paste0("(N=",after_stat(count),")")), size = 8.5/.pt, vjust = 1.1) +
      scale_x_discrete(limits = c("Round 1", "Round 2"), labels = c("Before\nthe reform", "After\nthe reform")) +
      labs(title = NULL, x = NULL, y = NULL) +
      coord_cartesian(xlim = c(0.6, 2.6), 
                      ylim = c(-(nrow(filter(BIBU.Finns, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.01, 
                               (nrow(filter(BIBU.Finns, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.01), 
                      expand = FALSE, 
                      clip = "off") +
      scale_y_continuous(breaks = seq(from = 0, 
                                      to = nrow(filter(BIBU.Finns, !is.na(COMPULSORY_SCHOOLING_BI)))/2, 
                                      by = nrow(filter(BIBU.Finns, !is.na(COMPULSORY_SCHOOLING_BI)))/10),
                         labels = c("0%", "20%", "40%", "60%", "80%", "100%")) +
      geom_rect(ymin = -(nrow(filter(BIBU.Finns, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.01, 
                ymax =  (nrow(filter(BIBU.Finns, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.01, 
                xmin = 2.4, 
                xmax = 2.6, 
                colour = "black", 
                fill = "grey90") +
      annotate("text", x = 2.5, y = (nrow(filter(BIBU.Finns, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.5, hjust = 0.5, vjust = 0.5, label = "True Finns", angle = 270, fontface = 2, size = 13/.pt) +
      theme(text = element_text(size = 12, color = "black"),
            axis.text.x = element_blank(),
            panel.grid.major.x = element_blank(),
            panel.grid.minor.x = element_blank(), 
            panel.grid.major.y = element_line(color = "grey90"),
            panel.grid.minor.y = element_line(color = "grey90"), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent", color = "transparent"),
            legend.position = "none", 
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.15, 0.05, 0.15, 0.05),"cm")),
    
    # General specs
    ncol = 3, widths = c(3, 4, 4.25),
    align = "hv")





# _ Movement Now ----------------------------------------------------------

# __ Data preparation -----------------------------------------------------
BIBU.MNow <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, RETIREMENT_TUBE_BI, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "Movement Now") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-count)

BIBU.MNow <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, COMPULSORY_SCHOOLING_BI, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "Movement Now") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-c(count, PartyChoice.Overall)) %>%
  full_join(., BIBU.MNow, by = c("MEMBERID", "ROUND"))

BIBU.MNow <-
  BIBU.DiD %>%
  select(MEMBERID, ROUND, LeftRight, PartyChoice.Overall) %>%
  filter(PartyChoice.Overall == "Movement Now") %>%
  na.omit() %>%
  group_by(MEMBERID) %>%
  mutate(count = n()) %>%
  filter(count == 2) %>%
  select(-c(count, PartyChoice.Overall)) %>%
  full_join(., BIBU.MNow, by = c("MEMBERID", "ROUND"))

BIBU.MNow$PartyChoice.Overall <- "Movement Now"




# __ Figure ---------------------------------------------------------------

MNow <-
  ggarrange(
    # Kernel density plot
    ggplot(filter(BIBU.MNow, !is.na(LeftRight) & ROUND == "Round 1"), 
           aes(x = LeftRight)) +
      geom_density(alpha = 0.65, 
                   bw = 0.75, 
                   color = brewer.pal(n = 9, name = "Greys")[5],
                   fill = brewer.pal(n = 9, name = "Greys")[3]) +
      geom_segment(x = mean(BIBU.MNow$LeftRight), 
                   xend = mean(BIBU.MNow$LeftRight), 
                   y = 0, 
                   yend = 0.258, 
                   color = brewer.pal(n = 9, name = "Greys")[7], 
                   linetype = "longdash") +
      scale_x_continuous(breaks = seq(0, 10, 1), labels = c("0", "\nLeft", "", "", "", "5", "", "", "", "\nRight", "10")) +
      scale_y_continuous(breaks = seq(0, 0.5, 0.05), labels = c("0.0", "", "0.1", "", "0.2", "", "0.3", "", "0.4", "", "0.5")) +
      labs(title = NULL, x = NULL, y = NULL, fill = NULL, color = NULL) +
      coord_cartesian(xlim = c(0 - 0.33, 10 + 0.33), ylim = c(0, 0.5 * 1.01), expand = FALSE, clip = "off") +
      theme(text = element_text(size = 12, color = "black"),
            panel.grid.major.x = element_blank(), 
            panel.grid.major.y = element_line(colour = "gray90"), 
            panel.grid.minor.y = element_blank(), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent"),
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.05, 0.2, 0.05, 0.05),"cm")),
    
    
    # Welfare retrenchment
    ggplot(filter(BIBU.MNow, !is.na(RETIREMENT_TUBE_BI)), 
           aes(x = ROUND, 
               stratum = RETIREMENT_TUBE_BI, 
               fill = as.factor(RETIREMENT_TUBE_BI), 
               alluvium = MEMBERID)) +
      scale_fill_manual(values = brewer.pal(n = 9, name = "Greys")[c(6, 4)]) +
      geom_flow(width = 0.75) +
      geom_stratum(alpha = 0.5, width = 0.75) + 
      geom_text(stat = "stratum", color = "black", aes(label = percent(after_stat(prop), accuracy = .1)), size = 11/.pt, vjust = -0.1) +
      geom_text(stat = "stratum", color = "black", aes(label = paste0("(N=",after_stat(count),")")), size = 8.5/.pt, vjust = 1.1) +
      scale_x_discrete(limits = c("Round 1", "Round 2"), labels = c("Before\nthe reform", "After\nthe reform")) +
      labs(title = NULL, x = NULL, y = NULL) +
      coord_cartesian(xlim = c(0.6, 2.4), 
                      ylim = c(-(nrow(filter(BIBU.MNow, !is.na(RETIREMENT_TUBE_BI)))/2)*0.01, 
                               (nrow(filter(BIBU.MNow, !is.na(RETIREMENT_TUBE_BI)))/2)*1.01), 
                      expand = FALSE, 
                      clip = "off") +
      scale_y_continuous(breaks = seq(from = 0, 
                                      to = nrow(filter(BIBU.MNow, !is.na(RETIREMENT_TUBE_BI)))/2, 
                                      by = nrow(filter(BIBU.MNow, !is.na(RETIREMENT_TUBE_BI)))/10),
                         labels = c("0%", "20%", "40%", "60%", "80%", "100%")) +
      theme(text = element_text(size = 12, color = "black"),
            panel.grid.major.x = element_blank(),
            panel.grid.minor.x = element_blank(), 
            panel.grid.major.y = element_line(color = "grey90"),
            panel.grid.minor.y = element_line(color = "grey90"), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent", color = "transparent"),
            legend.position = "none", 
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.15, 0.05, 0.15, 0.05),"cm")),
    
    
    # Welfare expansion
    ggplot(filter(BIBU.MNow, !is.na(COMPULSORY_SCHOOLING_BI)), 
           aes(x = ROUND, 
               stratum = COMPULSORY_SCHOOLING_BI, 
               fill = as.factor(COMPULSORY_SCHOOLING_BI), 
               alluvium = MEMBERID)) +
      scale_fill_manual(values = brewer.pal(n = 9, name = "Greys")[c(6, 4)]) +
      geom_flow(width = 0.75) +
      geom_stratum(alpha = 0.5, width = 0.75) + 
      geom_text(stat = "stratum", color = "black", aes(label = percent(after_stat(prop), accuracy = .1)), size = 11/.pt, vjust = -0.1) +
      geom_text(stat = "stratum", color = "black", aes(label = paste0("(N=",after_stat(count),")")), size = 8.5/.pt, vjust = 1.1) +
      scale_x_discrete(limits = c("Round 1", "Round 2"), labels = c("Before\nthe reform", "After\nthe reform")) +
      labs(title = NULL, x = NULL, y = NULL) +
      coord_cartesian(xlim = c(0.6, 2.6), 
                      ylim = c(-(nrow(filter(BIBU.MNow, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.01, 
                               (nrow(filter(BIBU.MNow, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.01), 
                      expand = FALSE, 
                      clip = "off") +
      scale_y_continuous(breaks = seq(from = 0, 
                                      to = nrow(filter(BIBU.MNow, !is.na(COMPULSORY_SCHOOLING_BI)))/2, 
                                      by = nrow(filter(BIBU.MNow, !is.na(COMPULSORY_SCHOOLING_BI)))/10),
                         labels = c("0%", "20%", "40%", "60%", "80%", "100%")) +
      geom_rect(ymin = -(nrow(filter(BIBU.MNow, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.01, 
                ymax =  (nrow(filter(BIBU.MNow, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*1.01, 
                xmin = 2.4, 
                xmax = 2.6, 
                colour = "black", 
                fill = "grey90") +
      annotate("text", x = 2.5, y = (nrow(filter(BIBU.MNow, !is.na(COMPULSORY_SCHOOLING_BI)))/2)*0.5, hjust = 0.5, vjust = 0.5, label = "Movement Now", angle = 270, fontface = 2, size = 13/.pt) +
      theme(text = element_text(size = 12, color = "black"),
            panel.grid.major.x = element_blank(),
            panel.grid.minor.x = element_blank(), 
            panel.grid.major.y = element_line(color = "grey90"),
            panel.grid.minor.y = element_line(color = "grey90"), 
            panel.background = element_rect(fill = "white"),
            plot.background = element_rect(fill = "white"),
            panel.border = element_rect(fill = "transparent", color = "transparent"),
            legend.position = "none", 
            axis.ticks = element_blank(),
            plot.margin = unit(c(0.15, 0.05, 0.15, 0.05),"cm")),
    
    # General specs
    ncol = 3, widths = c(3, 4, 4.25),
    align = "hv")





# _ Combined figure -------------------------------------------------------
annotate_figure(
  ggarrange(NatCol,
            ChristianDem,
            Other,
            TrueFinns,
            MNow,
            nrow = 5, heights = c(6.25, 5, 5, 5, 5.5)),
  right = get_legend(ggplot(filter(BIBU.MNow, !is.na(RETIREMENT_TUBE_BI)), 
                            aes(x = ROUND, 
                                stratum = RETIREMENT_TUBE_BI, 
                                fill = as.factor(RETIREMENT_TUBE_BI), 
                                alluvium = MEMBERID)) +
                       scale_fill_manual(values = brewer.pal(n = 9, name = "Greys")[c(6, 4)],
                                         labels = c("Strongly agree\nand agree", "Strongly disagree\nand disagree")) +
                       geom_flow(width = 0.75) +
                       geom_stratum(alpha = 0.5, width = 0.75) + 
                       guides(fill = guide_legend(byrow = TRUE)) +
                       labs(title = NULL, x = NULL, y = NULL, fill = NULL) +
                       theme(legend.spacing.y = unit(0.2, 'cm'),
                             legend.justification = c(0, 0.95))
  )
) + theme(plot.background = element_rect(fill = "white", color = "white"))


# Saving the output
ggsave(filename = "02-figures and models/Fig C1 - opposition parties overview.png", width = 27, height = 32.5, units = "cm", dpi = 600)



# Cleanup
rm(BIBU.NatC, BIBU.ChD, BIBU.Other, BIBU.Finns, BIBU.MNow)
rm(NatCol, ChristianDem, Other, TrueFinns, MNow)
rm(BIBU.DiD)
